using Godot;
using System;

public partial class Projectile : Area3D
{
    [Export] private float _speed = 30.0f;
    [Export] private int _damage = 25;

    //默认z轴方向的向量
    public Vector3 Direction = Vector3.Forward;

    public override void _PhysicsProcess(double delta)
    {
        Position += Direction * _speed * (float)delta;
    }

    public void onTimerTimeout()
    {
        QueueFree();
    }

    public void _on_area_entered(Area3D area)
    {
        if (area.IsInGroup("enemy_area"))
        {
            Enemy enemyCs = area.GetParent() as Enemy;
            enemyCs.CurrentHealth -= _damage;

            QueueFree();
        }
    }
}